package kr.hkit.androidcomplete02.ch19;

import kr.hkit.androidcomplete02.R;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.TextView;

public class LongTime2 extends Activity {
	int mValue;
	TextView tv;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch19_uploadex);

		tv = (TextView) findViewById(R.id.ch19_uploadex_tv);
	}

	Handler mHandler = new Handler() {
		public void handleMessage(android.os.Message msg) {
			if (msg.what == 0) {
				mValue++;
				tv.setText(Integer.toString(mValue));
				
				try {
					Thread.sleep(50);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				
				if (mValue < 100) {
					mHandler.sendEmptyMessage(0);
				}
			}
		};
	};

	public void mOnClick(View v) {
		mValue = 0;
		mHandler.sendEmptyMessage(0);
	}
}
